//
//  CJBaseTableView.m
//  CoJellyCartoon
//
//  Created by dllo on 16/3/30.
//  Copyright © 2016年 CJG. All rights reserved.
//

#import "CJBaseTableView.h"

@implementation CJBaseTableView

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"ChangeColor" object:nil];
}

-(instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style{
    
    self = [super initWithFrame:frame style:style];
    
    if (self) {
        
        NSString *str = [[NSUserDefaults standardUserDefaults] objectForKey:@"NightMode"];
        
        if ([str isEqualToString:@"Night"]) {
            self.backgroundColor = [UIColor lightGrayColor];
        }else{
            
            self.backgroundColor = [UIColor whiteColor];
        }
        
        ///接收通知
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeColor:) name:@"ChangeColor" object:nil];
        
    }
    
    return self;
}

- (void)changeColor:(NSNotification *)notification{
    
    
    NSString *str = [[NSUserDefaults standardUserDefaults] objectForKey:@"NightMode"];
    
    if ([str isEqualToString:@"Night"]) {
        self.backgroundColor = [UIColor lightGrayColor];
    }else{
        
        self.backgroundColor = [UIColor whiteColor];
    }
    
}



@end
